
package system.base;

//import com.v3.item.Catalog;
//import com.v3.util.StringFactory;

import system.data.ProductCategoryBase;
import framework.core.Conditions;
import framework.core.DBConnection;
import framework.core.DBEngine;
import framework.core.DBResult;
import framework.core.ObjectList;
import framework.core.Values;

/*
	Author    :Sindy
	CreateTime:2008-02-13 12:20:35
*/
public class ProductCategory extends ProductCategoryBase 
{

//----system generated start----// 	
public ProductCategory() 
{
	
}

private static void delete(DBConnection con,String id) throws Exception
{
	Conditions conditions = new Conditions();

	conditions.add(ID,id);
	
	delete(con,TABLE_NAME,conditions);
}
public static ProductCategory fetch()
{
	return new ProductCategory();
}
public static ProductCategory copy(ProductCategory srcObj)
{
	ProductCategory obj = fetch();
	obj.copyBase(srcObj);
	return obj;
}
public static ProductCategory fetch(DBConnection con,String id) throws Exception
{
	Conditions conditions = new Conditions();

	conditions.add(ID,id);
	
	return fetch(con,conditions);
}

public static ProductCategory fetchByCode(DBConnection con, String code) throws Exception
{
    Conditions conditions = new Conditions();
    conditions.add(CODE, code);
    return fetch(con,conditions);
}

public static ProductCategory fetch(DBConnection con,Conditions conditions) throws Exception
{
	DBResult result = null;
	try
	{
		result = DBEngine.doSelect(con,"select * from " + TABLE_NAME,conditions);
		java.sql.ResultSet rs = result.getRs();
		ProductCategory obj = null;
		if(rs.next())
		{
			obj = fetch(rs);
		}
		return obj;
	}
	finally
	{
		if(result!=null) result.clear() ;
	}
}
public static ProductCategory fetch(java.sql.ResultSet rs) throws Exception
{
	ProductCategory obj = new ProductCategory();
	obj.initObject(rs);
	return obj;
}
protected void getUnique(DBConnection con) throws Exception
{
		setId(DBEngine.getId(con));
}
//----system generated end----//



//----add by Sindy start----//
public static ObjectList fetchNo1Category(DBConnection con) throws Exception
{
    
    Values vs = new Values();
    DBEngine.checkCon(con);
    String sql = "select * from " + ProductCategory.TABLE_NAME + " where " + ProductCategory.CATEGORY_LEVEL + " = '1' ";
    
    DBResult result = DBEngine.doSelect(con,sql);
    
    ObjectList list = ObjectList.fromRs(ProductCategory.class,result.getRs());
    result.clear();
    return list;    

}


//封装产品分类
public static ObjectList getCategoryLevel1(DBConnection con) throws Exception{

    Conditions conditions = new Conditions();

    conditions.add(ProductCategory.CATEGORY_LEVEL,"1");
    
    ObjectList tManuf1 = ProductCategory.fetch().search(con, conditions);
    return tManuf1;
}
    
public static ObjectList getCategoryLevel2(DBConnection con) throws Exception{    
    //取得产品等级为2级的产品种类
    Conditions conditions = new Conditions();

    conditions.add(ProductCategory.CATEGORY_LEVEL,"2");
    
    ObjectList tManuf2 = ProductCategory.fetch().search(con, conditions);

    return tManuf2;
}    

public static ObjectList getCategoryLevel3(DBConnection con) throws Exception{    
    //取得产品等级为3级的产品种类
    Conditions conditions = new Conditions();

    conditions.add(ProductCategory.CATEGORY_LEVEL,"3");
    
    ObjectList tManuf3 = ProductCategory.fetch().search(con, conditions);
    
    return tManuf3;
} 

//----add by Sindy end----//

}

